#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

const int N = 2e5 + 10;

int n;
LL a[N], sum[N];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n;
    for(int i = 1; i <= n; i ++) cin >> a[i];
    for(int i = 1; i <= n; i ++) sum[i] = sum[i - 1] + a[i];

    LL res = 0;
    for(int i = 1; i <= n; i ++){
        res += a[i] * (sum[n] - sum[i]);
    }

    cout << res << '\n';

    return 0;
}